<template>
    <div class="search">
        <!-- 头部导航栏 -->
        <div class="head">
            <h3>食谱秀网</h3>
            <svg class="icon icon-caidan" aria-hidden="true" @click="show = !show">
                <use xlink:href="#icon-caidan"></use>
            </svg>
            <!-- 头部隐藏栏 -->
            <transition name="fade">
                <ul class="tab" v-if="!show">
                    <router-link to="/index">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-icons_statistics"></use>
                                </svg>
                                首页
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/classify">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                食材分类
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/Cookbook">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                菜谱大全
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/HomeCooked">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                家常菜谱
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/restriction">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-star"></use>
                                </svg>
                                食物相克
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/PregnantDiet">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                孕妇食谱
                            </span>
                        </li>
                    </router-link>
                    <router-link to="/FoodInformation">
                        <li>
                            <span>
                                <svg class="icon" aria-hidden="true">
                                    <use xlink:href="#icon-tag"></use>
                                </svg>
                                美食资讯
                            </span>
                        </li>
                    </router-link>
                </ul>
            </transition>
        </div>
        <!-- 搜索 -->
        <div class="sousuo">
            <svg class="icon icon-fangdajing" aria-hidden="true">
                <use xlink:href="#icon-fangdajing1"></use>
            </svg>
            <input type="text" class="sousuo1" placeholder="请输入关键字例:红烧排骨">
            <router-link to="/search">
                <input type="submit"  class="sousuo2" value="搜索">
            </router-link>
        </div>
        <!-- 中间 -->
        <div class="bottom">
            <div class="wu">
                提醒：如果没有找到你想要的食谱，可以点这里找找看>><br>
                官方微信号: <span style="color: #ff0000;">chaoliu1588 </span>
                ，分享最新的美食消息。
            </div>
        </div>
        <!-- 推荐部分 -->
        <div class="recommend">
            <li v-for="(item,index) in recommend" :key="index">
                <router-link to="/index">
                    <img :src="item.src" alt="">
                    <p>{{item.explanation}}</p>
                </router-link>
            </li>
        </div>
        <!-- 底部  -->
        <div class="foot">
            Copyright 食谱秀 m.shipuxiu.com <br>
            <p> 
                官方微信号: <span style="color: #ff0000;">chaoliu1588 </span> 
                <router-link to="https://m.shipuxiu.com/fenlei/">食谱分类</router-link>
                <router-link to="https://support.qq.com/products/113359/">我要吐槽</router-link>
                <router-link to="https://new.cnzz.com/v1/login.php?siteid=5433565">站长统计 </router-link>
             </p> 
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return{
            show:true,
            recommend:[]
        }
    },
    mounted(){
        // 获取数据
        this.$http.get('../../data/data.json')
        .then((response)=> {
            this.recommend = response.data.recommend
        })
        .catch(function (error) {
            console.log(error);
        })
        .then(function () {
            // always executed
        });
    }
}
</script>

<style scoped>
    /* 中间 */
    .bottom{
        width: 100%;
        height: 16vh;
        background: #ffffff;
        margin: 0px auto;
    }
    .bottom .wu{
        background: rgba(244, 244, 244, 0.5);
        width: 92%;
        height: 12vh;
        margin: 6px auto;
        font-size: 12px;
        color: #303030;
        padding-top: 10px;
    }
    /* 推荐部分 */
    .recommend{
        width: 100%;
        height: 24vh;
        padding-top: 60px;
        background: rgba(244, 244, 244, 0.5)
    }
    .recommend li{
        width: 30.5%;
        height: 10vh;
        margin-bottom: 6px;
        margin-left: -5px;
        position: relative;
    }
    .recommend li:nth-of-type(1),.recommend li:nth-of-type(4){
        margin-left: 10px;
    }
    .recommend li img{
        width: 100%;
        height: 10vh;
    }
    .recommend li p{
        position: absolute;
        top: 59px;
        right: 0px;
        z-index: 2;
        display: block;
        width: 100%;
        height: 2.3vh;
        font-size: 12px;
        text-align: center;
        color: #e4e2e1;
        background: #4b4b4b;
    }
    .recommend li a{
        text-decoration: none;
    }
    .foot{
        background: #f5f5f5;
        border-bottom: none;
        border-left: none;
        height: 40vh;
    }
</style>

